//
//  SerialView.swift
//  E-CycleForShop
//
//  Created by enghou on 17/3/10.
//  Copyright © 2017年 xyxorigation. All rights reserved.
//

import UIKit

class SerialView: UIView {

    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.layer.cornerRadius = YXButtonCorner
        self.layer.shadowColor = UIColor.colorWithHexString(hex: "b2b2b2").cgColor
        self.layer.shadowOffset = CGSize.init(width: 1, height: 1)
        self.layer.shadowOpacity = 0.7
        self.backgroundColor = UIColor.colorWithHexString(hex: "f9f9f9")
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func load(title : String,item1 : String,item2 : String)->Void{
        let titleBack = UIView.init(frame: CGRect.init(x: 0, y: 0, width: self.width(), height: 88 * YXHeightScale))
        titleBack.backgroundColor = UIColor.colorWithHexString(hex: "f8f9fb")
        self.addSubview(titleBack)
        let font = UIFont.systemFont(ofSize: 28 * YXWidthScale)
        let titleSize = title.StringSize(font: font)
        let ti = UILabel.init(frame: CGRect.init(x: 42 * YXWidthScale, y: 30 * YXHeightScale, width: titleSize.width, height: titleSize.height))
        ti.font = font
        ti.textColor = UIColor.colorWithHexString(hex: "323232")
        ti.text = title
        titleBack.addSubview(ti)
        
    }
    
    func feed(serial : String,typeid : String) -> Void {
        let itm1 = itemView(title: "序列号", hold: serial, frame: CGRect.init(x: 50 * YXWidthScale, y: 122 * YXHeightScale, width: 636 * YXWidthScale, height: 88 * YXHeightScale))
        self.addSubview(itm1)
        
//        let itm2 = itemView(title: "型 号", hold: typeid, frame: CGRect.init(x: itm1.left(), y: itm1.bottom() + 20 * YXHeightScale, width: 636 * YXWidthScale, height: 88 * YXHeightScale))
//        self.addSubview(itm2)
    }
    
    func itemView(title : String,hold : String,frame : CGRect) -> UIView {
        let back = UIView.init()
        back.frame = frame
        back.backgroundColor = UIColor.colorWithHexString(hex: "f3f4f5")
        back.layer.cornerRadius = YXButtonCorner
        back.layer.borderColor = UIColor.colorWithHexString(hex: "e5e5e5").cgColor
        let font = UIFont.systemFont(ofSize: 28 * YXWidthScale)
        let itemSize1 = title.StringSize(font: font)
        let itemLbl1 = UILabel.init(frame: CGRect.init(x: 28 * YXWidthScale, y: back.height() / 2 - itemSize1.height / 2, width: itemSize1.width, height: itemSize1.height))
        itemLbl1.textColor = UIColor.colorWithHexString(hex: "323232")
        itemLbl1.text = title
        itemLbl1.font = font
        back.addSubview(itemLbl1)
        
        let field = UILabel.init(frame: CGRect.init(x: 158 * YXWidthScale, y: itemLbl1.top(), width: 487 * YXWidthScale, height: itemLbl1.height()))
        field.text = hold
        field.font = font
        field.textColor = UIColor.colorWithHexString(hex: "b2b2b2")
        back.addSubview(field)
        return back
    }
    
    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */

}
